<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        // Object.defineProperties()
        var obj = {};
        Object.defineProperties(obj, {
            a: {
                enumerable: true,
                get() {
                    return this._a;
                },
                set(n) {
                    this._a = n;
                }
            },
            b: {
                get() {
                    return this._b
                },
                set(n) {
                    this._b = n;
                }
            }
        })

        // console.log(obj);

        var props = ['name', 'age', 'phone', 'address'];

        props.forEach(item => {
            Object.defineProperty(obj, item, {
                enumerable: true,
                get() {
                    return this['_' + item]
                },
                set(n) {
                    this['_' + item] = n;
                }
            })
        })




    </script>
</body>

</html>